package com.enthusiasm.frame;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.view.WindowManager;

import com.enthusiasm.constants.BitmapManager;
import com.enthusiasm.constants.Constants;
import com.enthusiasm.constants.SoundManager;
import com.young.R;

public class SplashActivity extends Activity {
    /** Called when the activity is first created. */
	private static final int  STARTGAME = 1;
	private static final int  DELAYTIME = 2000;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /*获取设备屏幕属性*/
        getScreenProperty();
        BitmapManager.getInstance(this);
        SoundManager.getInstance(this);
        /*LOGO页面加载*/
        Message msg = new Message();
        msg.what = STARTGAME;
        handler.sendMessageDelayed(msg, DELAYTIME);
    }
    
    private void getScreenProperty() {
    	DisplayMetrics dm = new DisplayMetrics();
		WindowManager win = (WindowManager)this.getSystemService(Context.WINDOW_SERVICE);
		win.getDefaultDisplay().getMetrics(dm);
		Constants.DENSITY= dm.density;
		Constants.WIDTH = dm.widthPixels;
		Constants.HEIGHT = dm.heightPixels;
		Constants.DPI = dm.densityDpi;
	}

	Handler handler = new Handler(){
    	public void handleMessage(Message msg) {
    		if(msg.what == STARTGAME){
    			Intent intent = new Intent(SplashActivity.this,GameMenuActivity.class);
    			startActivity(intent);
    			SplashActivity.this.finish();
    			overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
    		}
    	};
    };
	@Override
	protected void onStop() {
		super.onStop();
		SplashActivity.this.finish();
	}
}